package com.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import com.domain.User;

/**
 * @author 程序猿DD
 * @version 1.0.0
 * @param <T>
 * @date 16/3/17 下午6:44.
 * @blog http://blog.didispace.com
 */
@Service
public  class UserServiceImpl implements UserService {

    @Autowired
    private JdbcTemplate jdbcTemplate;

  
    public void create(String name, Integer age) {
        jdbcTemplate.update("insert into USER(NAME, AGE) values(?, ?)", name, age);
    }

   
    public void deleteByName(String name) {
        jdbcTemplate.update("delete from USER where NAME = ?", name);
    }

  
    public Integer getAllUsers() {
        return jdbcTemplate.queryForObject("select count(1) from USER", Integer.class);
    }

    public void deleteAllUsers() {
        jdbcTemplate.update("delete from USER");
    }
    
    
    public List<Map<String,Object>> getUsers(){
    	return jdbcTemplate.queryForList("select * from USER");
  
    }
    
    
      public Map<String,Object> getuser3s(){
    	  return jdbcTemplate.queryForMap("select * from USER where id=19");
    	  
    	 }
      
      
      public List<?> getuser4s()
      {
    	  return jdbcTemplate.queryForList("select * from USER");
      }
      
      /**获取用户信息5*/
      public List<?> getuser5s()
      {
    	  return jdbcTemplate.queryForList("select * from USER where id in ('20','21')");
      }
      
      /*获取信息6*/
        
      

		public List getList() {
			// TODO Auto-generated method stub
			return jdbcTemplate.queryForList("select * from USER");
		}


		@Override
		public List getList2() {
			// TODO Auto-generated method stub
			return jdbcTemplate.queryForList("select * from USER");
		}


		
        
    		
    	}
    
    
    

